home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 15 / BBS in a box XV-1.iso / Files / Tele / I-L / LineShare 3.1.3 Demo.sit / LineShare 3.1.3 Demo / LineShare Scripts / Fax Class1&ARA&Data < prev    next >
Encoding:
Text File  |  1995-01-03  |  8.3 KB  |  448 lines  |  [TEXT/sLiN]

  1. ! Version 3.1.0
  2. !
  3. !$ Use this script with Class 1 fax software working in the "numeric answers"
  4. !$ mode (FaxSTF,Faxilitate), ARA 1.0 or 2.0,
  5. !$ and a BBS, E-mail or other communication server software
  6. !
  7. !$ This script allows to place fax AND ARA/data calls, and it allows to receive
  8. !$ fax OR ARA/data calls.
  9. !
  10. !$ A cable for hardware handshaking is required
  11.  
  12. ^# Modem:
  13. ^2 Fax Software:     = Enum("FaxSTF™"="0","Faxilitate"="1") "0"
  14. ^3 Error Correction: = Bool("Enabled"="AUTO","Disabled"="NORM") "NORM"
  15. ^4 Incoming Calls:   = Enum("Fax"="0","ARA/Data"="1") "1"
  16. ^5 Data Port Speed:  = Enum("9600","19200","38400") "19200"
  17. ! ------------------------------------------
  18. ! Resetting the modem:
  19. ! ------------------------------------------
  20. @Hangup
  21.   SetTries 2
  22.   Flush
  23.   HsReset 0,0,17,19,0,0
  24.   DtrSet
  25. !
  26. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  27. ! to enter the command mode
  28. !
  29. @Label 1
  30.   matchclr
  31.   matchstr 1 2 "OK\r\n"
  32.   write "ATH0V1Q0\r"
  33.   matchread 20
  34.   ChrDelay 1
  35.   Write "+++"
  36.   ChrDelay 0
  37.   DtrClear
  38.   SBreak
  39.   DtrSet
  40. !
  41.   DecTries
  42.   IfTries 0 1
  43. !
  44. ! OSErr -6019 "Modem error - the modem is not responding"
  45. !
  46.   exit -6019
  47. @Label 2
  48.   SetVar A "&F"
  49.   GetOption A "DFLT" 3
  50. @Label 3
  51.   write "AT^A+FCLASS=0\r"
  52.   Jsr 100
  53.   exit 0
  54.  
  55. @Label 6
  56.   Say "This script cannot be used with this modem"
  57.   ifOriginate 9
  58.   pause 1800
  59. @Label 9
  60.   exit -6019
  61.  
  62. ! ------------------------------------------
  63. !    Receiving incoming calls
  64. ! ------------------------------------------
  65. @ANSWER
  66. !
  67. ! Set the modem preferred speed first
  68.   SerReset 19200,0,8,1
  69.   Jsr 80
  70.  
  71. @Label 10
  72. !
  73. ! Set the common options
  74.   Jsr 70
  75.  
  76. !
  77. ! Go to Fax receive if required
  78. !
  79.   ifStr 4 40 "0"
  80. !
  81. ! ARA/Data call waiting
  82. !
  83. !
  84. ! Set the desired speed
  85.   SerReset Val("^5"),0,8,1
  86.   Jsr 80
  87. !
  88. ! Set the data options
  89.   Jsr 75
  90.  
  91.   GetCommand B "Data" "M"
  92.   GetCommand C "Data" "L"
  93.   GetCommand D "Data" "S0"
  94.   SetVar A "S0=7"
  95.   ifStr D 16 "S0=0"
  96.   ifStr D 16 ""
  97.   SetVar A "^D"
  98. @Label 16
  99. !
  100. ! Set the speaker and S0
  101.   Write "AT^A^B^C\r"
  102.   Jsr 100
  103. !
  104. ! Everything is ready - let's sit and wait for a data call
  105. ! We'll wait for 2 minutes, then reinitiate the modem
  106. !
  107.   Note "Waiting for an ARA/DATA call…"
  108.   Jsr 90
  109.   IfStr C 10 "NONE"
  110.  
  111.   IfOpen "Data" 21
  112.   Jump 30
  113. @Label 21
  114.   IfOpen "ARA" 22
  115.   Jump 35
  116. @Label 22
  117.   Note "Waiting for an ARA frame"
  118.   MatchClr
  119.   MatchStr 1 23 "^$\r"
  120.   MatchStr 2 28 "\08\01\03\14\04\03\00\08\250\16\03"
  121.   MatchStr 3 29 "\01\27\02\29\01\02\01\06"
  122.   MatchRead 40
  123.   Jump 24
  124. @Label 23
  125.   QueueInput "^$\r"
  126. @Label 24
  127.   Note "Non-ARA call"
  128.   Jump 35
  129.  
  130. @Label 28
  131.   Note "ARA 1.0 call"
  132.   Jump 30
  133. @Label 29
  134.   Note "ARA 2.0 call"
  135.   Jump 30
  136.  
  137. @Label 30
  138.   QueueInput "\r\nCARRIER ^B\r\n"  
  139.   IfStr A 31 "NONE"
  140.   IfStr A 31 "None"
  141.   QueueInput "\r\nREL\r\n"
  142. @Label 31
  143.   IfOriginate 32
  144.   QueueInput "\r\nRING\r\n"
  145. @Label 32
  146.   Attach "ARA" (DTR)
  147.  
  148. @Label 35
  149.   GetSReg C "DATA" 4
  150.   QueueInput "\r^CCONNECT ^B\r^C"
  151.   ifOriginate 36
  152.   QueueInput "\r^CRING\r^C"
  153. @Label 36
  154.   HsReset 0,1,17,19,0,1
  155.   Attach "Data" (DTR,Escape,Break)
  156.  
  157. !
  158. ! Receiving Fax calls
  159. !
  160. @Label 40
  161.   Write "AT+FCLASS=1\r"
  162.   Jsr 100
  163. !
  164. ! Get the Speaker and the Ring Num options
  165.   GetCommand B "Fax" "M"
  166.   GetCommand C "Fax" "L"
  167.   GetCommand D "Fax" "S0"
  168.   SetVar A "S0=7"
  169.   ifStr D 41 "S0=0"
  170.   ifStr D 41 ""
  171.   SetVar A "^D"
  172. @Label 41
  173. !
  174. ! Set the speaker and S0, switch to the numeric mode.
  175.   Write "AT^A^B^CV0\r"
  176.   Jsr 110
  177. !
  178. ! Everything is ready - let's sit and wait for a fax call
  179. ! We'll wait for 2 minutes, then reinitiate the modem
  180.   Note "Waiting for a fax call…"
  181.   Jsr 85
  182.   IfStr C 49 "NONE"
  183. !
  184. ! Fax connection has been established (we read "CONNECT")
  185. ! Put the CONNECT ("1\r") back to the buffer,
  186. ! if it was an incoming call, put the "RING" before it
  187. @Label 45
  188.   QueueInput "1\r"
  189.   ifOriginate 47
  190. @Label 46
  191.   QueueInput "2\r2\r"
  192. @Label 47
  193.   Attach "Fax" (DTR,Reset(2400),IdleLimit=30)
  194.  
  195. @Label 49
  196.   Write "ATV1\r"
  197.   Jsr 100
  198.   Jump 40
  199. ! ------------------------------------------
  200. ! Originating a call through the "ARA" subport
  201. ! ------------------------------------------
  202. @ORIGINATE "ARA"
  203.   SerReset Val("^5"),0,8,1
  204.   Jsr 80
  205. !
  206. ! Set the common options
  207.   Jsr 70
  208. !
  209. ! Set the communication options:
  210.   Jsr 75
  211. !
  212. ! Emit the ARA script commands ("Xnn")
  213.   Jsr 60
  214. !
  215. ! dial the number
  216.   Write "ATD^1\r"
  217. !
  218. ! Wait for a modem response
  219.   Jsr 90
  220.   IfStr C 30 "DATA"
  221.   Write "\r"
  222.   Exit -6019
  223.  
  224. ! ------------------------------------------
  225. ! Originating a call through the "DATA" subport
  226. ! ------------------------------------------
  227. @ORIGINATE "Data" ("\r\nLineShare Line is Busy\r\nBUSY\r\n")
  228.   SerReset 19200,0,8,1
  229.   Jsr 80
  230. !
  231. ! Set the common options
  232.   Jsr 70
  233. !
  234. ! Set the communication options:
  235.   Jsr 75
  236. !
  237. ! dial the number
  238.   Write "ATD^1\r"
  239.   HsReset *
  240. !
  241. ! Wait for a modem response
  242.   Jsr 90
  243.   IfStr C 35 "DATA"
  244.   Write "\r"
  245.   Exit -6019
  246.  
  247. ! ------------------------------------------
  248. ! Originating a call through the "Fax" subPort
  249. ! ------------------------------------------
  250. @ORIGINATE "Fax" ("\r\nLineShare Line is Busy\r\nBUSY\r\n")
  251. !
  252. ! Set the "Fax" speed
  253. !
  254.   SerReset 19200,0,8,1
  255.   Jsr 80
  256. !
  257. ! Set the common options
  258. !
  259.   Jsr 70
  260.   GetOption A "SWHS" 6
  261. !
  262. ! Set the Fax mode (Xon/Xoff)
  263.   Write "AT^A+FCLASS=1\r"
  264.   Jsr 100
  265. !
  266. ! Now emit all commands that the application has sent to that port,
  267. ! except "+FCLASS", etc
  268. !
  269.   EmitClear "+FCLASS","V","E"
  270.   Jsr 60
  271. !
  272. ! Prepare to receive all error result codes, dial the number
  273. !
  274.   Write "ATV0D^1\r"
  275.   HsReset *
  276.   Jsr 85
  277.   IfStr C 45 "FAX"
  278.   Write "\r"
  279.   Exit -6019
  280. !
  281. !
  282. ! This section emits all modem commands sent from the client application
  283. ! For each set of commands the "OK" answer is awaited
  284. !
  285. @Label 60
  286.   EmitStart
  287. @Label 61
  288.   EmitCommand 62
  289.   Jsr 100
  290.   Jump 61
  291. @Label 62
  292.   return
  293. !
  294. ! This section initiates the modem before ANSWER and ORIGINATEs:
  295. ! extended responses + connect at the highest rate + speaker control +
  296. ! reset on Dtr drop + DCD valid
  297. ! Verbal responses mode, no echo 
  298. !
  299. @Label 70
  300.   Write "AT&D2&C1V1E0\r"
  301.   Jsr 100
  302.   return 
  303.  
  304. ! Set the communication options:
  305. ! • Normal/AUTO Connection
  306. ! • HW flow control  (for ARA, Fax should not use a handshake on receiving)
  307. ! • CONNECT <DCE speed> or CARRIER/CONNECT
  308. @Label 75
  309.   GetOption A "HWHS" 6
  310.   GetOption B "^3" 6
  311.   GetOption C "LNRS" 6
  312.   Write "AT^A^B^C\r"
  313.   Jump 100
  314.  
  315. !
  316. ! This section syncronize the modem after the serial port speed switching
  317. !
  318. @Label 80
  319.   ChrDelay 1
  320.   Write "AT\r"
  321.   ChrDelay 0
  322.   Jsr 100
  323.   return
  324. !
  325. ! Error Codes
  326. @Label 81
  327.   exit -6020
  328. @Label 82
  329.   exit -6022
  330. @Label 83
  331.   exit -6021
  332. @Label 84
  333.   exit -6023
  334.  
  335. !
  336. ! Connecting in the numeric mode (fax)
  337. ! On exit:
  338. ! ^C contains "NONE" if no connection has been established
  339. @Label 85
  340.   MatchClr
  341.   MatchStr 1 88 "1\r"
  342.   MatchStr 2 87 "2\r"
  343.   MatchStr 5 81 "6\r"
  344.   MatchStr 6 82 "7\r"
  345.   MatchStr 7 83 "3\r"
  346.   MatchStr 8 84 "8\r"
  347. @Label 86
  348.   Matchread 1200
  349.   SetVar C "NONE"
  350.   return
  351.  
  352. @Label 87
  353.   Note "Ring…"
  354.   Jump 86
  355. @Label 88
  356.   SetVar C "FAX"
  357.   return
  358.  
  359. !
  360. ! This subroutine waits for the modem response (data mode)
  361. ! On exit:
  362. ! ^A contains the protocol used
  363. ! ^B contains the carrier speed
  364. ! ^C contains "NONE" if no connection has been established
  365. ! If modem reports an error, the scripts exits with an error code
  366. !
  367. @Label 90
  368.   SetVar A "NONE"
  369.   SetVar B ""
  370.   MatchClr
  371.   Matchstr 1 92 "CARRIER ^$\r\n"
  372.   Matchstr 2 93 "PROTOCOL: ^$\r\n"
  373.  
  374.   Matchstr 4 95 "CONNECT ^$/"
  375.   Matchstr 5 97 "CONNECT ^$\r\n"
  376.   Matchstr 6 94 "RING\r\n"
  377.   Matchstr 10 82 "BUSY\r\n"
  378.   MatchStr 11 83 "NO CARRIER\r\n"
  379.   MatchStr 12 84 "NO ANSWER\r\n"
  380. @Label 91
  381.   Matchread 1200
  382.   SetVar C "NONE"
  383.   return
  384.  
  385. @Label 92
  386.   SetVar B "^$"
  387.   Jump 91
  388. @Label 93
  389.   SetVar A "^$"
  390.   Jump 91
  391. @Label 94
  392.   Note "Ring…"
  393.   Jump 91
  394.  
  395.  
  396. ! CONNECT xxxx/XXXX was detected
  397. @Label 95
  398.   Jsr 98
  399.   MatchClr
  400.   MatchStr 1 96 "^$\r\n"
  401.   MatchRead 10
  402. @Label 96
  403.   SetVar A "^$"
  404.   SetVar C "DATA"
  405.   return
  406.  
  407. ! CONNECT xxx was detected
  408. @Label 97
  409.   Jsr 98
  410.   SetVar C "DATA"
  411.   return
  412.  
  413. @Label 98
  414.   ifStr B 99 ""
  415.   return
  416. @Label 99
  417.   SetVar B "^$"
  418.   return 
  419.  
  420. !
  421. ! Processing an AT command:
  422. ! OK -> proceed
  423. ! ERROR or TimeOut ->exit -6019
  424. ! It can be called AFTER the "Write" command, since LineShare buffers input
  425. !
  426. @Label 100
  427.   MatchClr
  428.   MatchStr 1 103 "\r\nOK\r\n"
  429.   MatchStr 2 102 "\r\nERROR\r\n"
  430. @Label 101
  431.   MatchRead 20
  432. @Label 102
  433.   Exit -6019
  434. @Label 103
  435.   return
  436.  
  437. !
  438. ! Processing an AT command in the numeric mode
  439. ! OK -> proceed
  440. ! ERROR or TimeOut ->exit -6019
  441. ! It can be called AFTER the "Write" command, since LineShare buffers input
  442. !
  443. @Label 110
  444.   MatchClr
  445.   MatchStr 1 103 "0\r"
  446.   MatchStr 2 102 "4\r"
  447.   Jump 101
  448.